package net.hn.hnms.biz.power.domain;

import com.fasterxml.jackson.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 智呈物联 pan'sx
 * 2022/9/20 10:50
 * 1.0 version
 */
@ApiModel("供电检测点位")
@Entity
@Table(name = "dwd_gdjk_base_sensorinfo", schema = "gdjk", catalog = "huaneng-production")
@Data
@JsonIdentityInfo(generator = ObjectIdGenerators.None.class, property = "deviceInfo")
//@NamedEntityGraph(name="SensorInfo.sensorMonitor",attributeNodes = {@NamedAttributeNode("sensorMonitor")@NamedAttributeNode("sensorMonitor")})
public class SensorInfo implements Serializable {
    @Id
    @ApiModelProperty("测点编码")
    private String pointCode;

    @ApiModelProperty("测点类型编码")
    private String pointTypeCode;

    @ApiModelProperty("测点类型名称")
    private String pointTypeName;

    @ApiModelProperty("所属设备")
    @ManyToOne
    @JoinColumn(name = "device_code")
    @JsonBackReference(value = "deviceInfo")
//    @JsonIgnore
    private DeviceInfo deviceInfo;

    @ApiModelProperty("测点位置")
    private String pointLocation;

    @ApiModelProperty("单位")
    private String pointValueUnit;

    @ApiModelProperty("量程上限")
    private BigDecimal upperLimitRange;

    @ApiModelProperty("报警下限")
    private BigDecimal lowerLimitRange;

    @ApiModelProperty("传感器关系(无用，恒为NULL)")
    private String pointRel;

    @ApiModelProperty("安装日期")
    @JsonFormat(
            pattern = "yyyy-MM-dd",
            timezone = "Asia/Shanghai"
    )
    private Date installTime;

    @ApiModelProperty("上传日期")
    @JsonFormat(
            pattern = "yyyy-MM-dd",
            timezone = "Asia/Shanghai"
    )
    private Date uploadTime;

    @ApiModelProperty("创建时间")
    @JsonFormat(
            pattern = "yyyy-MM-dd",
            timezone = "Asia/Shanghai"
    )
    private Date createTime;

    @ApiModelProperty("煤矿编码")
    private String mineCode;

    @OneToOne(fetch = FetchType.LAZY,mappedBy ="sensorInfo" )
    @ApiModelProperty("实时值")
    @JsonIgnore
    private NowSensorMonitor sensorMonitor;

    @ApiModelProperty("测点值")
    @Transient
    private BigDecimal pointValue;


    @ApiModelProperty("测点状态")
    @Transient
    private Integer pointStatus;

    @ApiModelProperty("数据时间")
    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm:ss",
            timezone = "Asia/Shanghai"
    )
    @Transient
    private Date dataTime;

}
